import { defineStore } from 'pinia'
export const useKeepAliveStore = defineStore(
  'layout-keepAlive',
  () => {
    const keepAliveName = ref<string[]>([])

    // Add KeepAliveName
    async function addKeepAliveName(name: string) {
      !keepAliveName.value.includes(name) && keepAliveName.value.push(name)
    }
    // Remove KeepAliveName
    async function removeKeepAliveName(name: string) {
      keepAliveName.value = keepAliveName.value.filter(item => item !== name)
    }
    // Set KeepAliveName
    async function setKeepAliveName(keepAN: string[] = []) {
      keepAliveName.value = keepAN
    }

    return { keepAliveName, addKeepAliveName, removeKeepAliveName, setKeepAliveName }
  },
  {
    persist: true,
  }
)
